<?php


namespace app\crontab\model;

use think\Db;
use think\Model;

class HouseVillage extends Model {

    protected $table = 'erp_house_village';

    /**获取小区房源列表
     * @param $map
     * @param $column
     * @param $page
     * @param $size
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function get_list($map, $column, $page, $size) {
        $arr = Db::name('house_village')
            ->where($map)
            ->field($column)
            ->page($page, $size)
            ->select();
        $list['data'] = $arr;
        $list['total'] = Db::name('house_village')
            ->where($map)
            ->count();
        $list['num'] = page_num($list['total'], $size);
        return $list;
    }

    /**
     * 获取小区房源详情
     * @param $id
     * @return mixed
     */
    static function get_detail($id, $column) {
        return Db::name('house_village')
            ->alias('hv')
            ->join('house h', 'h.village_id = hv.id', 'LEFT')
            ->field($column)
            ->find($id);
    }

}
